/**
 * 意见反馈
 */
import api from '../../tools/api'
// import {SUCCESS_STATUS} from '../../config/status'
import promise from '../../tools/promise'
import {
  OPINION_LIST,
  OPINION_SAVEDATA
} from '../mutation-types'

const state = {
  pageData: {
    total: 1,
    per_page: 15,
    current_page: 1,
    last_page: 1
  },
  opinionList: [],
  saveData: {}
}

const mutations = {
  [OPINION_LIST] (state, payload) {
    state.opinionList = payload.data
  },
  [OPINION_SAVEDATA] (state, data) {
    state.saveData = data
  }
}

const actions = {
  // 获取意见反馈列表
  async opinionList ({commit}, payload) {
    let listRes = await api('serversubmitform/submitform/Submitform/getSuggestionList', payload)
    commit(OPINION_LIST, listRes.res)
  },
  // 标记已读
  async opinionRead ({commit}, payload) {
    let readRes = await api('serversubmitform/submitform/Submitform/remarkRead', payload)
    return promise(readRes)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
